import Mock from "mockjs";
//处理路径传参
import { parameteUrl } from "@/utils/queryParam";
import { getUrlParamByKey } from "@/utils";
import { mapLayerEnum } from "@/enums";
import issueListData from "./mockData/issueListData.json";
import projectUpdateData from "./mockData/projectUpdateData.json";
import rectificationData from "./mockData/rectificationData.json";

function ArrSet(Arr: any[], id: string): any[] {
  let obj: any = {};
  const arrays = Arr.reduce((setArr, item) => {
    obj[item[id]] ? "" : (obj[item[id]] = true && setArr.push(item));
    return setArr;
  }, []);
  return arrays;
}
/**
 * @description: min ≤ r ≤ max  随机数
 * @param {*} Min
 * @param {*} Max
 * @return {*}
 */
function RandomNumBoth(Min: any, Max: any) {
  var Range = Max - Min;
  var Rand = Math.random();
  var num = Min + Math.round(Rand * Range); //四舍五入
  return num;
}
//左中
export default [
  {
    url: "/bigscreen/layer",
    type: "get",
    response: (config: any) => {
      console.log(config);
      const type = getUrlParamByKey(config.url, "type");
      console.log("type", type);
      const dataObject = {
        [mapLayerEnum.ISSUE]: issueListData,
        [mapLayerEnum.PROJECT]: projectUpdateData,
        [mapLayerEnum.RECTIFICATION]: rectificationData,
      };
      let data = null;
      if (type) {
        data = dataObject[type as mapLayerEnum];
      }
      const a = Mock.mock({
        success: true,
        data,
      });

      return a;
    },
  },
];
